
   {% if 'msg' in pdc.keys() %}
   <!-- 隐藏框里面放关于增删改查的信息--> 
         <input type='hidden' value="{{pdc.msg[0]}}" id="showdownbox" />
   	   {% set res = pdc.msg[0] %}
          {% endif %}
      <input type='hidden' value="{{request.args.get('res','')}}" id="res_arg" /><!-- 如果删除成功后信息将显示在这里 -->
     <div class="dropshowdown">
         <span style="font-size:25px;font-family: 楷体;">{{res}}{{request.args.get('res','')}}</span>  <!-- 信息弹出框-->
     </div>

	<p align="left"> <button class="btn btn-primary" data-toggle="modal" data-target="#myModal">去新加</button></p>  
	  <form method="post" action="/admin_pclass?name={{name}}">
	  <Label>宠物类别名:<input name="pclass" value="{{ request.values.get('pclass','')}}"></Label>
	  <input class="btn btn-primary" type="submit" value="查询" id="my_button">
	  <input type="hidden" name="msg1" id="msg1" value="{{request.values.get('msg1','')}}">
	<table width="100%" class="table table-bordered table-striped table-hover">
				<tr>
					<th>宠物类型编号</th><th>宠物类型</th><th>操作</th>
				</tr>
				{% for c in pdc.page.items %}
				<tr id="tr1">
					<td>{{ c.id }}</td>
					<td>{{ c.fk }}</td>
					<td>
						<a href="pclassdel/{{c.id}}/{{pdc.page.page}}" onclick="return confirm('你确定删除吗？')" >删除</a>
						<a href="#" class="edita" data-toggle="modal" data-target="#myModal2">编辑</a>
					</td>
				</tr>
			{% endfor %}
			</table>
	<div style="text-align: center;">
				总记录条数:{{pdc.page.total}} 每页显示记录数:{{ pdc.page.per_page }} 总页数:<span id="allPage">{{pdc.page.pages}}</span>
				<input class="btn btn-default" type="button" value="首页" onclick="toPage(1)" {% if pdc.page.page == 1 %}disabled{%endif%}>
				<input class="btn btn-default" type="button" value="上一页" onclick="toPage({{pdc.page.prev_num}})" {% if pdc.page.page == 1 %}disabled{%endif%}>
				当前页:<input value="{{pdc.page.page}}" size="3" name="currpage" onchange="toPage(this.value)">
				<input class="btn btn-default" type="button" value="下一页" onclick="toPage({{pdc.page.next_num}})" {% if pdc.page.page == pdc.page.pages %}disabled{%endif%}>
				<input class="btn btn-default" type="button" value="末页" onclick="toPage({{pdc.page.pages}})" {% if pdc.page.page == pdc.page.pages %}disabled{%endif%}>
				<script>
					function toPage(val){//val表示当前页
						//获取总页数
						allPage = document.getElementById("allPage").innerText
						if(val>allPage)val = allPage
						currpageObj = document.querySelector("input[name='currpage']")
						currpageObj.value = val
						document.forms[0].submit() //form表单提交
					}
					function onclickbtn(){   $("#my_button").click(function() {
							$("#msg1").val("点击了")				
							  });  }
							  
							function clear(){
								
								document.getElementById('msg1').value = ''
							}
						onclickbtn();	  
					setInterval('clear()',1000);
				</script>
			</div>		
	  </form>
	  
<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
              <div class="modal-dialog">
                  <div class="modal-content">
                      <div class="modal-header">
						  <h4 class="modal-title" id="myModalLabel">宠物类别信息新加</h4>
                          <button class="close" data-dismiss="modal" aria-hidden="true">&times;关闭</button>
                      <h4 class="modal-title" id="myModalLabel">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</h4>
                      </div>
                      <div class="modal-body">
                          <form class="form-horizontal" id="addform" role="form" method="post" action="/addpclass">
                              <div class="form-group">
                                  <label for="sid" class="col-sm-3 control-label">宠物类型编号</label>
                                  <div class="col-sm-9">
									  <input type="hidden" name='lastpage' value="{{pdc.page.pages}}">
									  <input type="hidden" name='current_page' value="{{pdc.page.page}}">
                                      <input type="text" class="form-control" name="classid" id="classid" value="自动分配" readonly>
                                  </div>
                              </div>
                              <div class="form-group">
                                  <label for="sname" class="col-sm-3 control-label">宠物类型</label>
                                  <div class="col-sm-9">
                                      <input type="text" class="form-control" name="classname" id="classname" placeholder="宠物类型">
                                  </div>
                              </div>
                              <input type="submit" value="提交" id="addbut" style="display: none;">
                          </form>
                      </div>
                      <div class="modal-footer">
                          <button class="btn btn-default" data-dismiss="modal">关闭</button>
                          <button class="btn btn-primary" id="submitbut">提交</button>
                      </div>
                  </div>
              </div>
          </div>
            <!--新加模态框结束-->
        <script>
              $(function(){
                  $("#submitbut").click(function(){
                          $("#addbut").click()
                  });
              })
          </script>
		  
  <!-- 修改模态框 -->
        <div id="myModal2" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
						<h4 class="modal-title" id="myModalLabel2">宠物类型编辑</h4>
                        <button class="close" data-dismiss="modal" aria-hidden="true">&times;关闭</button>
						   <h4 class="modal-title" id="myModalLabel">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</h4>
                    </div>
                    <div class="modal-body">
                        <form class="form-horizontal" id="modform" role="form" method="post" action="/updatepclass">
                            <div class="form-group">
                                <label for="sid2" class="col-sm-2 control-label">宠物类型编号</label>
                                <div class="col-sm-10">
									<input type="hidden"" value="{{pdc.page.page}}" name="currentpage">
                                    <input type="text" class="form-control" name="pclassidu" id="pclassidu" readonly>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="sname2" class="col-sm-2 control-label">宠物类型</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" name="pclassu" id="pclassu" placeholder="宠物类型">
                                </div>
                            </div>
                            <input type="submit" value="提交" id="modbut" style="display: none;">
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button class="btn btn-primary" id="submitbut2">提交</button>
                    </div>
                </div>
            </div>
        </div>
							<script>
					$(function(){

						$(".edita").click(function(){
							//获取当前点击
							   trobj= $(this).parents('tr');
							   pclassidu = trobj.find("td:eq(0)").text()
							   pclassu = trobj.find("td:eq(1)").text()
							   

							   $('#pclassidu').val(pclassidu)
							   $('#pclassu').val(pclassu)
						})

									$("#submitbut2").click(function(){
											$("#modbut").click()
									});
					})

							</script>
	   <script>
		   function showDropdown() {
		   				  
		                     var dropdown = document.querySelector('.dropshowdown'); 
		   				   //获取修改增加后的提示信息
		   				  try{ 
		   					  var flagmy = document.getElementById('showdownbox').value;
		   				  }catch(err){}
		   				
		   				 var res_arg = document.getElementById('res_arg').value;
		   			   
		   				if(res_arg == '删除成功!'){
		   					dropdown.style.display = 'block';
		   						setTimeout(() => {  
		   						    dropdown.style.display = 'none';  
		   							res_arg.value =null
		   						}, 2000); 	
		   				}
		   				
		   				switch(flagmy){
		   				 case('宠物类别信息添加成功!'):
		   					 dropdown.style.display = 'block';
		   					 	setTimeout(() => {  
		   					 	    dropdown.style.display = 'none';  
		   					 		flagmy.value =null
		   					 	}, 2000); 
		   				 case('宠物类别信息添加失败!可能为类别名重复'):	
		   				     dropdown.style.display = 'block';
		   				     	setTimeout(() => {  
		   				     	    dropdown.style.display = 'none';  
		   							flagmy.value =null
		   				     	}, 2000); 
		   				case('宠物类别信息修改成功!'):
		   				    dropdown.style.display = 'block';
		   				    	setTimeout(() => {  
		   				    	    dropdown.style.display = 'none';  
		   							flagmy.value =null
		   				    	}, 2000); 	
		   				case('宠物类别信息修改失败!可能为类别名重复'):
		   				    dropdown.style.display = 'block';
		   				    	setTimeout(() => {  
		   				    	    dropdown.style.display = 'none';  
		   							flagmy.value =null
		   				    	}, 2000); 	
		   					
		   				} /* switch结束*/
		   				
		   				
		                 }/*showDropdown()结束*/ 
		   showDropdown()
	   </script>   